package com.jacklin.controller;

import com.jacklin.service.SecondKillService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author 林必昭
 * @Date 2019/4/27 23:14
 *
 */
@Slf4j
//@Controller
@RestController
@RequestMapping("/skill")
public class SecondKillController {


    @Autowired
    private SecondKillService secondKillService;

    /**
     * 查询秒杀活动商品信息
     * @param productId
     * @return
     */
    @GetMapping("/query/{productId}")
    public String query(@PathVariable String productId){
        return secondKillService.querySecondKillProductInfo(productId);
    }

    /**
     * 秒杀
     * @param productId
     * @return
     */
    @GetMapping("/order/{productId}")
    public String kill(@PathVariable String productId){
        log.info("当前秒杀商品id",productId);
        secondKillService.orderProductMockDiffUser(productId);
        return secondKillService.querySecondKillProductInfo(productId);

    }
}
